package com.one.consumer.user.presenter;

import android.content.Context;

import com.one.common.model.extra.DefaultExtra;
import com.one.common.model.http.callback.ObserverOnResultListener;
import com.one.common.presenter.BaseApiPresenter;
import com.one.common.view.base.BaseActivity;
import com.one.consumer.order.model.OrderModel;
import com.one.consumer.user.model.item.InvoiceItem;
import com.one.consumer.user.ui.view.InvoiceView;

/**
 * author ：zhulunjun
 * email  ：zhulunjun@qq.com
 * date   ：2018/11/4 9:39 PM
 * description ：发票详情
 **/
public class InvoiceDetailPresenter extends BaseApiPresenter<InvoiceView, OrderModel> {
    private DefaultExtra extra;
    public InvoiceDetailPresenter(InvoiceView mView, Context mContext) {
        super(mView, mContext, new OrderModel((BaseActivity) mContext));
    }

    @Override
    public void onCreate() {
        super.onCreate();
        extra = (DefaultExtra) mActivity.getIntent().getSerializableExtra(DefaultExtra.getExtraName());
    }

    /**
     * 获取发票详情
     */
    public void getDetail(){
        if(extra!=null) {
            mModel.invoiceDetail(extra.getStr(), new ObserverOnResultListener<InvoiceItem>() {
                @Override
                public void onResult(InvoiceItem o) {
                    if(o!=null) {
                        mView.setDetail(o);
                    }
                }
            });
        }
    }
}
